#ifndef MAINQUO_H
#define MAINQUO_H
#include <QObject>
#include <QList>

#include <QMutex>
#include "Main/global.h"
#include "View/TreeModel.h"
#include <QQmlApplicationEngine>
#include "qtquickcontrolsapplication.h"
#include "Net/riskserver.h"
#include "ColumnConfig.h"
#include "almListModel.h"
#include "fileconfig.h"
#include "Net/tradeserver.h"
//#include "comboData.h"

//typedef QVector<QString> QuData;
//class QQmlApplicationEngine;
//class QtQuickControlsApplication;
class MainQuo : public QObject
{
    Q_OBJECT
public:
    MainQuo();
    ~MainQuo();
    
    //登录
    Q_INVOKABLE int doLogin(QString qsName, QString qsPwd);
    Q_INVOKABLE QString getPopMsg();
    Q_INVOKABLE TreeModel* getTreeMenu();
    Q_INVOKABLE TreeModel* getBranchStat();

    Q_INVOKABLE void openMenu(const QModelIndex &index);

    void SetEngine(QQmlApplicationEngine* pEngine, QtQuickControlsApplication* pApp);
    void ShowLogin();
    void ShowMainWnd();

    //注销
    Q_INVOKABLE void logout();
    Q_INVOKABLE void savePassword(bool bSave);

    //锁屏验证密码
    Q_INVOKABLE bool checkPassword(QString pwd);

    //双击机构清单的一行，查找记录大于0时返回真
    Q_INVOKABLE bool dbClickBranchStat(const QModelIndex &index);

    //打开风险客户
    Q_INVOKABLE bool openRiskCustList(const QModelIndex &index);

    Q_INVOKABLE AlmListModel* getRiskCustModel(const QString tabName, const QString qsCondition);
    CColumnConfig* GetColumnConfig();
    FileConfig* GetFileConfig();

    //获取后台交易时间
    Q_INVOKABLE QString getTradeTime( );

    //查询客户信息3063
    Q_INVOKABLE RspInterface* getCustDetail(const QString acctNo);

    //发送3066强平单
    Q_INVOKABLE RspInterface* sendForceOrder(const QString acctNo,const QString orderInfo);

    //3070撤单
    Q_INVOKABLE QString cancelForceOrder(const QString qsOrderNo);

    //3097 发送平仓试算
    Q_INVOKABLE RspInterface* tryCalcRiskInfo(const QString acctNo,const QString reqInfo);

    //3065 未全部成交的强平单查询
    Q_INVOKABLE RspInterface* queryPartMatchCovOrder(const QString reqInfo);

    //3098 查询合约价格
    Q_INVOKABLE RspInterface* queryProdPrice(const QString reqInfo);

    //3093 风险试算
    Q_INVOKABLE RspInterface* riskTestCalc(const QString reqInfo);

    //获取操作员所属机构及直属机构
    Q_INVOKABLE ComboData* getMyBranchs();

    //获取强平客户
    Q_INVOKABLE AlmListModel* getForceCustModel(int nTop,const QString qsCondition);

    //获取合约代码
    Q_INVOKABLE QStringList getSomeProdCode(const QStringList qsMarketList);
    //获取机构下的客户级别
    Q_INVOKABLE ComboData* getCustGradeByBranchs(const QString qsBranchId,bool bAll=true);

    //3069 强平单查询
    Q_INVOKABLE RspInterface* queryForceOrder(const QString reqInfo);

    //3095 机构风险客户数查询(风险度分布图)
    Q_INVOKABLE RspInterface* queryRiskCustCount(const QString reqInfo);

    //3096 机构风险客户数查询(风险度分布图)
    Q_INVOKABLE RspInterface* queryAgentRiskCustCount(const QString reqInfo);

    //3091 实时风险客户一览 /客户风险统计信息查询
    Q_INVOKABLE RspInterface* queryRiskCustStatics(const QString reqInfo);

    //3094 风险客户一览
    Q_INVOKABLE RspInterface* queryHisRiskCustList(const QString reqInfo);

    //3064 风险提示查询
    Q_INVOKABLE RspInterface* queryRiskTip(const QString reqInfo);

    //3081 风险分段设置
    Q_INVOKABLE RspInterface* operRiskDegree(const QString reqInfo);

    //根据客户级别id获取客户级别名称
    Q_INVOKABLE QString getCustGradeName(const QString qsID);

    //根据代理机构id获取代理机构名称
    Q_INVOKABLE QString getBranchName(const QString qsID);
    Q_INVOKABLE QString getBranchID(const QString qsName);

    //3309 批量生成强平单
    Q_INVOKABLE RspInterface* createBatchForceOrder(const QString reqInfo);

    Q_INVOKABLE QStringList getTypeTest();
protected:
    void InitTreeMenu();
    void InitRiskWatch(const ArrayListMsg alm);
    void InitRiskWatchRoles();
    QList<QVariant> GetBranchRecord( ArrayListMsg alm);
private:
    QString        m_qsPopMsg;
    TreeModel*     m_pTreeMenu;
    TreeModel*     m_pRiskWatchGrid;
    QQmlApplicationEngine* m_pEngine;
    QtQuickControlsApplication* m_pApp;
    RiskServer      m_riskServer;
    TradeServer     m_tradeServer;
    CColumnConfig	m_colCfg;
    FileConfig      m_config;
};

#endif // MAINQUO_H
